/*---------------------------------------------------------------------------
;	c8051libdef.h - 8051lib global defines and macros include file
;
;	Copyright (C) 2007 Our AMCT Corp.
; 	All rights reserved.
;	
;	License Type:	BSD
;	
;	Author:			Xu Chenxiang
;	File Version:	v0.1 (2007/07/11)
;	
;	File History:
;	v0.1 	Inital Release
;	
;		
;	
;	
;---------------------------------------------------------------------------*/

#ifndef C8051LIBDEF_H
#define C8051LIBDEF_H

#include "c8051f120.h"

#define P4_P7_Bit_Access(BitName,BitValue) \
{	SFRPAGE = CONFIG_PAGE;\
	BitName = BitValue;\
	SFRPAGE = LEGACY_PAGE;\
}

#define sbi(RegisterName,BitName,SfrPageName) \
{	u08 sfr_temp = SFRPAGE; \
	SFRPAGE = SfrPageName; \
	RegisterName |= 1<<BitName; \
	SFRPAGE = sfr_temp; \
}

#define cbi(RegisterName,BitName,SfrPageName) \
{	u08 sfr_temp = SFRPAGE; \
	SFRPAGE = SfrPageName; \
	RegisterName &= ~(1<<BitName); \
	SFRPAGE = sfr_temp; \
}
	




#define MIN(a,b)	((a<b)?(a):(b))
#define MAX(a,b)	((a>b)?(a):(b))
#define ABS(x)		((x>0)?(x):(-x))




#define PI	3.1415926535



#endif
